#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;
map<long long,int> mp;
int a[100010];
int main(){
    int n;
    cin >> n;
    long long val = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        val += a[i];
        mp[val] ++;
    }
    int ans = 0;
    for(auto p:mp){
        ans = max(ans,p.second);
    }
    cout << n-ans << endl;
    return 0;
}
